<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>合众人寿公益平台客户管理系统</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<link href="<%=request.getContextPath()%>/html/css/Main.css"
			rel="stylesheet" type="text/css" />
		<script src="<%=request.getContextPath()%>/html/js/Calendar.js"
			charset="utf-8"></script>
        
         <!-- Dwr Js -->
		<script
			src="<%= request.getContextPath() %>/dwr/interface/organizationAction.js"
			type="text/javascript"></script>
		<script src="<%= request.getContextPath() %>/dwr/engine.js"
			type="text/javascript"></script>
		<script src="<%= request.getContextPath() %>/dwr/util.js"
			type="text/javascript"></script>
		<script src="<%= request.getContextPath() %>/html/js/subCityUtil.js"
			type="text/javascript"></script>
        
        
        <style>
		body,ul,ol,dl,dd,p,h1,h2,h3,h4,h5,h6,form,input,textarea,select,td,th{margin:0;padding:0; font-family:"宋体",Arial, Helvetica, sans-serif;}
		li{ list-style:none;}
		input{ background:none;}
		.clear{ zoom:1;}
		.clear:after{content:""; display:block; clear:both;}
		</style>
        
		<SCRIPT type="text/javascript">
     function check(){
     	if(document.getElementById("activityDate").value == ''){
     	   alert("请输入活动日期!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("enjoyActivity").value) == ''){
     	   alert("请输入专享项目!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("organizeFee").value )== ''){
     	   alert("请输入组织经费!");
     	   return false;
     	}
     	if(document.getElementById("organizeFee").value < 0 || isNaN(document.getElementById("organizeFee").value)){
     	   alert("组织经费不合法!");
     	   return false;
     	}
     	
     	if(document.getElementById("participantsNum").value == ''){
     	   alert("请输入参与人数!");
     	   return false;
     	} 
     	if(document.getElementById("participantsNum").value.search(/^\d+$/)== -1){
     	   alert("参与人数不合法!");
     	   return false;
     	} 
     	if(leftTrim(document.getElementById("activityPlace").value) == ''){
     	   alert("请输入活动地点!");
     	   return false;
     	} 
     	if(document.getElementById("subCompany").value == ''){
     	   alert("请选择所分公司!");
     	   return false;
     	}
     	if(document.getElementById("subCity").value == ''){
     	   alert("请选择中支机构!");
     	   return false;
     	} 
     	if(document.getElementById("participantsNum").value == ''){
     	   document.getElementById("participantsNum").value = 0;
     	} 
     	if(leftTrim(document.getElementById("oaSph").value) == ''){
     	   alert("请输入OA审批号!");
     	   return false;
     	} 
     	document.getElementById("subComName").value = document.getElementById("subCompany").options[document.getElementById("subCompany").selectedIndex].innerText;
     	document.getElementById("subCityName").value = document.getElementById("subCity").options[document.getElementById("subCity").selectedIndex].innerText;
     	return true;
     }
     
     function   leftTrim(ui){  
	    var   notValid=/^\s/;  
	    while(notValid.test(ui)){  
	      ui=ui.replace(notValid,"");}  
       return   ui; 
       }  
	 </SCRIPT>

	</head>

	<body>
		<div class="container">
			<div class="wrap clear">
				<div class="sub_wp_right">
					<div class="rt_tt">
						<h3 class="tittle">
							添加会员专享活动
						</h3>
					</div>
					<div class="ct">
						<form
							action="<%=request.getContextPath()%>/memberEnjoy/saveMemberEnjoy.do"
							method="post" onsubmit="return check()">
							<div class="add">

								<table>
								 <tr>
									<td  align="right">
										<span>活动日期<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
										<input type="text" name="memberEnjoy.activityDate"
											id="activityDate" onfocus="calendar()"/>
									</td>
									<td  align="right">
										<span>专享项目<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
										<input type="text" name="memberEnjoy.enjoyActivity"
											id="enjoyActivity" />
									</td>
								</tr>
								<tr>
									<td  align="right">
										<span>组织经费<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
										<input type="text" name="memberEnjoy.organizeFee"
											id="organizeFee" />
									</td>
									<td  align="right">
										<span>参与人数<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
										<input type="text" name="memberEnjoy.participantsNum"
											id="participantsNum" />
									</td>
								</tr>
								<tr>
									<td align="right">
										<span>分公司<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
									   <c:if test="${rolename eq 'ADMIN'}">
										<select name="memberEnjoy.subCompany" onchange="ajaxSubmit()" id="subCompany" >
											<option selected="selected">
												请选择分公司
											</option>
											<s:iterator value="#session.barchList" var="organ">
												<option value="<s:property value="#organ.um_organ_id" />"
												 <c:if test="${memberEnjoy.subCompany eq  organ.um_organ_id}">selected</c:if> >
													<s:property value="#organ.abbr_name" />
												</option>
											</s:iterator>
										</select>
										</c:if>
										<c:if test="${rolename ne 'ADMIN'}">
										<select name="memberEnjoy.subCompany" id="subCompany" >
											<s:iterator value="#session.barchList" var="organ">
												<option value="<s:property value="#organ.um_organ_id" />"
												 <c:if test="${memberEnjoy.subCompany eq  organ.um_organ_id}">selected</c:if> >
													<s:property value="#organ.abbr_name" />
												</option>
											</s:iterator>
										</select>
										</c:if>
									</td>
									
									<td align="right">
										<span>中支<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
									    <c:if test="${rolename ne 'THIRDADMIN'}">
											<select name="memberEnjoy.subCity" id="subCity">
												<option selected="selected">
													请选择中支机构
												</option>
												<s:iterator value="#session.expensedList" var="organ">
													<option value="<s:property value="#organ.um_organ_id" />"
													 <c:if test="${memberEnjoy.subCity eq organ.um_organ_id }">selected</c:if> >
														<s:property value="#organ.abbr_name" />
													</option>
												</s:iterator>
											</select>
										</c:if>
										 <c:if test="${rolename eq 'THIRDADMIN'}">
										 	<select name="memberEnjoy.subCity" id="subCity">
										 	<s:iterator value="#session.expensedList" var="organ">
													<option value="<s:property value="#organ.um_organ_id" />"
													 <c:if test="${memberEnjoy.subCity eq organ.um_organ_id }">selected</c:if> >
														<s:property value="#organ.abbr_name" />
													</option>
												</s:iterator>
											</select>
										 </c:if>
										<input type="hidden" value="${subCityHidden}"
											name="subCityHidden" />
									</td>
                                  </tr>
								<tr>
									<td  align="right">
										<span>活动地点<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
										<input type="text" name="memberEnjoy.activityPlace"
											id="activityPlace" />
									</td>
									<td  align="right">
										<span>OA审批号<font color="red">(*)</font>：</span>
									</td>
									<td class="t2">
										<input type="text" name="memberEnjoy.oaSph"
											id="oaSph" />
									</td>
								</tr>
								<tr>
                                    <td>
                                      <input type="hidden" name="memberEnjoy.subComName" id="subComName"/>
                                    </td>
                                    <td>
                                      <input type="hidden" name="memberEnjoy.subCityName" id="subCityName"/>
                                    </td>
                                  </tr>
								</table>
							</div>
							<div class="btn">
								<input type="submit" value="保存" />
								<input type="button" value="返回"
									onclick="javascript :history.back(-1);" />
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
